package com.zqh.myfmmall.controller;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zqh.myfmmall.entity.Users;
import com.zqh.myfmmall.result.Result;
import com.zqh.myfmmall.service.UsersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

/**
 * 用户 (Users)表控制层
 *
 * @author KONO 曾淇杭哒！
 * @since 2022-01-20 02:35:22
 */
@RestController
@RequestMapping("user")
@Api(tags = "用户管理")
public class UsersController{
    @Resource
    private UsersService usersService;


    @ApiOperation("用户登录接口")
    @ApiImplicitParams({@ApiImplicitParam(dataType = "String", value = "用户名称", name = "username", required = true),
                        @ApiImplicitParam(dataType = "String", value = "用户密码", name = "password", required = true),})
    @GetMapping("login")
    public Result login(@RequestBody Users user) {
        return usersService.login(user.getUsername(),user.getPassword());
    }

    @ApiOperation("用户注册接口")
    @ApiImplicitParams({@ApiImplicitParam(dataType = "String", value = "用户名称", name = "username", required = true),
                        @ApiImplicitParam(dataType = "String", value = "用户密码", name = "password", required = true)})
    @PostMapping("register")
    public Result register(@RequestBody Users user) {
        return usersService.regist(user.getUsername(),user.getPassword());
    }
}

